/* 
 * Product javascript
 * @author: lethanhquang910@gmail.com
 */

/**
 * Get top new product ajax
 */
function get_top_new_product(contentId)
{
    try
    {
        $.ajax({
            type: 'POST',
            url: siteurl + '/product/topNewProduct',
            dataType: 'html',
            success: function(data)
            {
                //Append data to content
                $('#'+contentId).html(data);
            }
        });
    }
    catch(ex)
    {
        console.log(ex);
    }

    //return data
    return false;
}

/**
 * Add product to cart
 */
function add_to_cart(pid)
{
    $.ajax({
        type: 'POST',
        url: siteurl + '/cart/addToCart',
        data: {pid:pid},
        dataType: 'json',
        success: function()
        {
            //nothing
        }
    });

    //return data
    return false;
}

/**
 * Remove product from cart
 */
function remove_from_cart(pid)
{
    $.ajax({
        type: 'POST',
        url: siteurl + '/cart/removeFromCart',
        data: {pid:pid},
        dataType: 'json',
        success: function()
        {
            //nothing
        }
    });

    //return data
    return false;
}


